package com.financing.platform.dao.impl;

import java.util.List;
import com.financing.platform.dao.impl.BaseDaoImpl;
import com.financing.platform.dao.IFpFundMCDao;
import com.financing.platform.dto.FpFundMCDTO;
import com.financing.platform.util.SqlName;
import java.sql.SQLException;
import java.util.Collections;

import org.springframework.stereotype.Repository;

/**
 * @Description:实现类
 * @author caojiayao
 * @version 1.0
 * @created 
 */
@Repository("fpFundMC")
public class FpFundMCDaoImpl extends BaseDaoImpl implements IFpFundMCDao {
	
	@Override
	public FpFundMCDTO getFpFundMC(Integer id) {
		try{
			return (FpFundMCDTO)this.sqlMapClient.queryForObject(SqlName.fpFundMC,id);
		} catch (SQLException e) {
			log.error("get fpFundMC error:",e);
			return null;
		}
	}
	
	
	@Override
	public Integer insertFpFundMC(FpFundMCDTO dto) {
		try {
		     return (Integer) this.sqlMapClient.insert(SqlName.insertFpFundMC,dto);
		} catch (SQLException e) {
			log.error("add fpFundMC error:",e);
			return 0;
		}
	}

	
	@Override
	public Integer updateFpFundMC(FpFundMCDTO dto) {
		try {
			return (Integer) this.sqlMapClient.update(SqlName.updateFpFundMC, dto);
		} catch (SQLException e) {
			this.log.error("update fpFundMC error 1!",e);
			return 0;
		}
	}
	
	@Override
	public Integer delFpFundMC(Integer id) {
		try{
			 return (Integer) this.sqlMapClient.delete(SqlName.delFpFundMC, id);
		} catch (SQLException e) {
			log.error("del fpFundMC error:",e);
			return 0;
		}
	}
	
	@Override
	public List<FpFundMCDTO> listFpFundMC(FpFundMCDTO dto) {
		try {
			return (List<FpFundMCDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundMC, dto);
		} catch (SQLException e) {
			log.error("Query fpFundMC note list error !", e);
			return Collections.emptyList();
		}
	}
	
	@Override
	public List<FpFundMCDTO> listFpFundMCByPage(FpFundMCDTO dto) {
		try {
			return (List<FpFundMCDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundMCByPage, dto);
		} catch (SQLException e) {
			log.error("Query fpFundMC note list error !", e);
			return Collections.emptyList();
		}
	}
	
	
	public Integer countFpFundMC(FpFundMCDTO dto){
		try {
			return (Integer)this.sqlMapClient.queryForObject(SqlName.countFpFundMC, dto);
		} catch (SQLException e) {
			log.error("Query fpFundMC note list error !", e);
			return 0;
		}
	}
	
}
